#include "StdAfx.h"
#include "ResourceManager.h"

ResourceManager* ResourceManager::instance = new ResourceManager();

ResourceManager* ResourceManager::GetInstance()
{
	return instance;
}

ResourceManager::ResourceManager(void)
{
	LocationsFile = "Locations.txt";
	LoadLocations();
	LoadCommands();
}

ResourceManager::~ResourceManager(void)
{
	ClearVector(&fLocations);
	ClearVector(&fCommands);
}

void ResourceManager::LoadLocations()
{
	vector<FileLine*> lines;
	FileIO::LoadFile(lines,LocationsFile);
	for (unsigned int i = 0; i < lines.size(); ++i)
	{
		Location* loc = new Location("");
		loc->Description = lines[i]->tokens[0];
		fLocations.push_back(loc);
	}
	ClearVector(&lines);
}

void ResourceManager::SaveLocations() const
{
	vector<FileLine*> lines;
	for (unsigned int i = 0; i < fLocations.size(); ++i)
	{
		Location* loc = fLocations[i];
		FileLine* line = new FileLine();
		line->tokens.push_back(loc->Description);
		lines.push_back(line);
	}
	FileIO::SaveFile(lines,LocationsFile);
	ClearVector(&lines);
}

void ResourceManager::LoadCommands()
{
}

void ResourceManager::SaveCommands() const
{
}



